package com.ddh.codeduck.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.codeduck.pojo.entity.SysDictType;
import com.codeduck.pojo.req.SysDictTypePageReq;
import com.ddh.codeduck.service.ISysDictTypeService;
import com.ddhcodeduck.common.result.BaseResponse;
import com.ddhcodeduck.common.result.ResultUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 字典类型表 前端控制器
 * </p>
 *
 * @author ddh
 * @since 2025-07-11
 */
@RestController
@RequestMapping("/sys-dict-type")
@Api(tags = "字典类型表")
public class SysDictTypeController {

    @Resource
    private ISysDictTypeService sysDictTypeService;

    /**
     * 字典类型列表(分页)
     *
     * @param sysDictTypePageReq
     * @return
     */
    @PostMapping("/list")
    @ApiOperation("字典类型列表(分页)")
    public BaseResponse<IPage<SysDictType>> sysDictTypePage(@RequestBody SysDictTypePageReq sysDictTypePageReq) {
        IPage<SysDictType> sysDictTypeIPage = sysDictTypeService.sysDictTypePage(sysDictTypePageReq);
        return ResultUtils.success(sysDictTypeIPage);
    }

    /**
     * 根据id查询字典类型
     */
    @GetMapping("/getById")
    @ApiOperation("根据id查询字典类型")
    public BaseResponse<SysDictType> sysDictTypeGetById(String id) {
        SysDictType sysDictTypeById = sysDictTypeService.getById(id);
        return ResultUtils.success(sysDictTypeById);
    }

    /**
     * 新增或者修改字典类型表
     */
    @PostMapping("/saveOrUpdate")
    @ApiOperation("新增或者修改字典类型表")
    public BaseResponse<Boolean> sysDictTypeSaveOrUpdate(@RequestBody SysDictType sysDictType) {
        return ResultUtils.success(sysDictTypeService.saveOrUpdate(sysDictType));
    }

    /**
     * 批量删除字典类型表
     */
    @PostMapping("/removeBatchByIds")
    @ApiOperation("批量删除字典类型表")
    public BaseResponse<Boolean> sysDictTypeRemoveBatchByIds(@RequestBody List<String> ids) {
        return ResultUtils.success(sysDictTypeService.removeBatchByIds(ids));
    }
}
